<?php
class bobot_m extends CI_Model{
	
	function simpan_bobot(){
		$this->db->select_max('id_bobot','max_id');
		$id_la = $this->db->get('db_bobot');
		foreach ($id_la->result() as $id_ba){
			$id_lam = $id_ba->max_id;
		}
		if ( $id_lam==0 ){
			$id_bar = 40001;
		}
		else {
			$id_bar = $id_lam+1;
		}
		$waktu = date('Y-m-d');
		$data = array(
			'id_bobot' => $id_bar,
			'p_n' => $this->input->post('p'),
			'e_n' => $this->input->post('e'),
			'a_n' => $this->input->post('a'),
			'r_n' => $this->input->post('r'),
			'l_n' => $this->input->post('l'),
			's_n' => $this->input->post('s'),
			'nama_b' => $this->input->post('nama'),
			'waktu_b' => $waktu
		);
		return $this->db->insert('db_bobot', $data);
	}
	
	function ambil(){
		$hasil = $this->db->get('db_bobot');
		if ($hasil->num_rows() > 0){
			foreach ($hasil->result() as $data){
				$data1[] = $data;
			}
			return $data1;
		}
	}
}
?>